package com.anycl.design.j2ee.transferobject;

import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * 业务对象，提供业务数据
 */
@Getter
public class BusinessObject {
    // 数据来源的存储容器
    private List<TransferObject> list;

    public BusinessObject() {
        list = new ArrayList<>();
        list.add(new TransferObject(0, "Java"));
        list.add(new TransferObject(1, "MySQL"));
    }

    public TransferObject getDataById(int index) {
        return list.get(index);
    }

    public void update(TransferObject transferObject) {
        list.get(transferObject.getId()).setName(transferObject.getName());
    }
}
